<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="jquery.min.js"></script>
    <link rel="stylesheet" href="css/eye.css">
</head>

<body>
    <div class="box">
        <label>
          <img src="images/close.png" id="eye">
        </label>
        <input type="password" id="pwd">
    </div>
    <script>
        var flag = 0;
        $("#eye").click(
            function() {
                if (flag == 0) {
                    $("#pwd").prop("type", "text");
                    $(this).attr('src', 'images/open.png')
                    flag = 1;
                } else {
                    $("#pwd").prop("type", "password");
                    $(this).attr('src', 'images/close.png')
                    flag = 0;
                }
            }
        )
    </script>
</body>

</html>